﻿using MediatR;
using S.Archives.Domain.S.ArchivesModel;
using S.Archives.Infrstructre.InterFace;
using S.Archives.Read.Api.Application.Command;
using System.Reflection;

namespace S.Archives.Read.Api.Application.CommandHandlers
{
    public class GetWanderCommandHandler : IRequestHandler<GetWanderCommand, List<WanderModel>>
    {
        private readonly IWanderRepository wanderRepository;
        public GetWanderCommandHandler(IWanderRepository wanderRepository)
        {
            this.wanderRepository = wanderRepository;
        }

        public async Task<List<WanderModel>> Handle(GetWanderCommand request, CancellationToken cancellationToken)
        {
           return wanderRepository.GetAllAsync().Result.Where(x=>x.EarTag == request.EITag).ToList();
        }
    }
}
